package com.hiray.wanandroid

import androidx.compose.runtime.Composable
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow


class GameViewModel : ViewModel() {

    private val _flow = MutableStateFlow(SnakeState(action = Action.GameTick))
    val stateFlow = _flow.asStateFlow()

}

enum class Direction {
    Bottom,
    Top,
    Left,
    Right,
}

enum class Action {
    GameTick,
    GameOver
}

data class SnakePart(val x: Int, val y: Int)


data class SnakeState(
    var action: Action,
    val direction: Direction = Direction.Bottom,
    val snakeBody: MutableList<SnakePart> = mutableListOf(SnakePart(10, 10)),
    val freeSnakePart: SnakePart = SnakePart(15, 15),
    var Width_Matrix: Int = 0,
    var Height_Matrix: Int = 0,
    var isRunning: Boolean = true
)


@Composable
fun BaseScreen() {

}

@Composable
fun GameScreen() {

}

@Composable
fun SnakeJoy() {

}

@Composable
fun OperateBody() {

}

@Composable
fun GameButton() {

}

@Composable
fun DirectionButton(direction: Int) {

}